package view;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;

import model.Kunde;

public class ModifyUserInDetail extends Component
{
	private Container cont;
	private Kunde customer;
	
	private JLabel headLine;
	private JLabel firstName;
	private JLabel lastName;
	private JLabel adressOfBill;
	private JLabel nameOfCompany;
	private JLabel discount;
	private JLabel telephone;
	private JLabel email;
	private JLabel fax;
	private JLabel web;
	private JLabel notice;
	

	private JTextField firstNameTextField;
	private JTextField lastNameTextField;
	private JTextField addressOfBillTextField;
	private JTextField nameOfCompanyTextField;
	private JTextField discountTextField;
	private JTextField telephoneTextField;
	private JTextField emailTextField;
	private JTextField faxTextField;
	private JTextField webTextField;

	private JTextField noticeTextArea;

	private JButton saveCustomerButton;
	private JButton cancelButton;
	

	public ModifyUserInDetail(Container cont, Kunde customer)
	{
		this.cont = cont;
		this.customer = customer;
		this.initCreateCustomerView();
	}

	public void initCreateCustomerView()
	{

		SpringLayout layout = new SpringLayout();
		this.cont.setLayout(layout);
		this.cont.setSize(700, 400);
		System.out.println("Created:");
		this.headLine = new JLabel("Please fill out the form:");
		this.firstName = new JLabel("First Name:");
		this.firstNameTextField = new JTextField(this.customer.getVorname(), 20);
		this.lastName = new JLabel("Last Name:");
		this.lastNameTextField = new JTextField(this.customer.getNachname(), 20);
		this.adressOfBill = new JLabel("Adress:");
		this.addressOfBillTextField = new JTextField(this.customer.getRechnungsadresse(), 20);
		this.nameOfCompany = new JLabel("Company:");
		this.nameOfCompanyTextField = new JTextField(this.customer.getFirmenname(), 20);
		this.discount = new JLabel("Discount:");
		this.discountTextField = new JTextField(String.valueOf(this.customer.getRabat()), 20);
		this.telephone = new JLabel("Telephone:");
		this.telephoneTextField = new JTextField(this.customer.getTelefon(), 20);
		this.email = new JLabel("Email:");
		this.emailTextField = new JTextField(this.customer.getEmail(), 20);
		this.fax = new JLabel("Fax:");
		this.faxTextField = new JTextField(this.customer.getFax(), 20);
		this.web = new JLabel("Homepage:");
		this.webTextField = new JTextField(this.customer.getWeb(), 20);
		this.notice = new JLabel("Notice");
		this.noticeTextArea = new JTextField(this.customer.getNotiz(), 20);
		this.saveCustomerButton = new JButton("Save Changes");
		this.cancelButton = new JButton("Cancel Csutomer");
		

		this.adressOfBill = new JLabel("Address:");
		this.cont.add(headLine);
		this.cont.add(firstName);
		this.cont.add(firstNameTextField);
		this.cont.add(lastName);
		this.cont.add(lastNameTextField);
		this.cont.add(adressOfBill);
		this.cont.add(addressOfBillTextField);
		this.cont.add(nameOfCompany);
		this.cont.add(nameOfCompanyTextField);
		this.cont.add(discount);
		this.cont.add(discountTextField);
		this.cont.add(telephone);
		this.cont.add(telephoneTextField);
		this.cont.add(email);
		this.cont.add(emailTextField);
		this.cont.add(fax);
		this.cont.add(faxTextField);
		this.cont.add(web);
		this.cont.add(webTextField);
		this.cont.add(notice);
		this.cont.add(noticeTextArea);
		this.cont.add(saveCustomerButton);
		this.cont.add(cancelButton);

		layout.putConstraint(SpringLayout.WEST, headLine, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, headLine, 5, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, firstName, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, firstName, 30, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, firstNameTextField, 5, SpringLayout.EAST, firstName);
		layout.putConstraint(SpringLayout.NORTH, firstNameTextField, 30, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, lastName, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, lastName, 55, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, lastNameTextField, 5, SpringLayout.EAST, lastName);
		layout.putConstraint(SpringLayout.NORTH, lastNameTextField, 55, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, adressOfBill, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, adressOfBill, 80, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, addressOfBillTextField, 10, SpringLayout.EAST, adressOfBill);
		layout.putConstraint(SpringLayout.NORTH, addressOfBillTextField, 80, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, nameOfCompany, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, nameOfCompany, 105, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, nameOfCompanyTextField, 5, SpringLayout.EAST, nameOfCompany);
		layout.putConstraint(SpringLayout.NORTH, nameOfCompanyTextField, 105, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, discount, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, discount, 130, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, discountTextField, 5, SpringLayout.EAST, discount);
		layout.putConstraint(SpringLayout.NORTH, discountTextField, 130, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, telephone, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, telephone, 155, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, telephoneTextField, 5, SpringLayout.EAST, telephone);
		layout.putConstraint(SpringLayout.NORTH, telephoneTextField, 155, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, email, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, email, 180, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, emailTextField, 5, SpringLayout.EAST, email);
		layout.putConstraint(SpringLayout.NORTH, emailTextField, 180, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, fax, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, fax, 205, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, faxTextField, 5, SpringLayout.EAST, fax);
		layout.putConstraint(SpringLayout.NORTH, faxTextField, 205, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, web, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, web, 230, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, webTextField, 5, SpringLayout.EAST, web);
		layout.putConstraint(SpringLayout.NORTH, webTextField, 230, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, notice, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, notice, 255, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, noticeTextArea, 5, SpringLayout.EAST, notice);
		layout.putConstraint(SpringLayout.NORTH, noticeTextArea, 255, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, saveCustomerButton, 5, SpringLayout.WEST, cont);
		layout.putConstraint(SpringLayout.NORTH, saveCustomerButton, 280, SpringLayout.NORTH, cont);
		layout.putConstraint(SpringLayout.WEST, cancelButton, 5, SpringLayout.EAST, saveCustomerButton);
		layout.putConstraint(SpringLayout.NORTH, cancelButton, 280, SpringLayout.NORTH, cont);

		this.cont.setVisible(true);

	}

	public void addActionsListeners(ActionListener a1)
	{
		saveCustomerButton.addActionListener(a1);
		cancelButton.addActionListener(a1);
	}

	public JButton getSaveCustomerButton()
	{
		return saveCustomerButton;
	}

	public void setSaveCustomerButton(JButton saveCustomerButton)
	{
		this.saveCustomerButton = saveCustomerButton;
	}

	public JButton getCancelButton()
	{
		return cancelButton;
	}

	public void setCancelButton(JButton cancelButton)
	{
		this.cancelButton = cancelButton;
	}

}
